package com.example.mysampleapp.fragment;

import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.myfirstapp.R;

public class BookDescFragment extends Fragment {
	String[] mChapterSummary;
	TextView mChapterSummaryTextView;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View viewHierarchy = inflater.inflate(R.layout.fragment_book_desc,
				container, false);
		// Load array of chapter summary
		mChapterSummary = getResources()
				.getStringArray(R.array.summary_chapter);

		// Get reference to chapter summary text view
		mChapterSummaryTextView = (TextView) viewHierarchy
				.findViewById(R.id.chapter_summary);
		mChapterSummaryTextView.setText(mChapterSummary[0]);
		return viewHierarchy;
	}

	public void setBook(int bookIndex) {
		// Lookup the chapter summary
		String bookDescription = mChapterSummary[bookIndex];
		// Display it
		mChapterSummaryTextView.setText(bookDescription);
	}

}
